package com.yonyou.pmclouds.workstopreport.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.workstopreport.entity.WorkStopVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class WorkStopInsertCheckProcessor implements SingleProcessor<WorkStopVO> {
    @Override
    public void process(WorkStopVO vo, WorkStopVO orig) throws BusinessException {
        if (null == vo) {
            throw new BusinessException("单据不能为空！");
        }
        if (null == vo.getStopDate()) {
            throw new BusinessException("停工日期不能为空！");
        }
        if (null == vo.getPreresumeDate()) {
            throw new BusinessException("预计复工日期不能为空");
        }
        if (null == vo.getWorkstopdays()) {
            throw new BusinessException("停工天数不能为空");
        }
        if(vo.getWorkstopdays() < 0){
            throw new BusinessException("停工天数不能为负数！");
        }
        if (null == vo.getWorkstopreason() || "".equals(vo.getWorkstopreason().trim()) ) {
            throw new BusinessException("停工原因不能为空");
        }
        if(vo.getWorkstopreason().length() > 300){
            throw new BusinessException("停工原因最多只能有300个字！");
        }
    }
}
